library(survey)
library(dplyr)
library(stargazer)
library(performance)

## creating Model for Table 3.3 
# model: multivariate model based on demographics, logit specification, DV: Q11_d

summary(factor(df$Q11))
summary(factor(df$Q11_d))


## Create weighted survey design object
w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df
  )

## creating Model for Table 3.3 
# model: multivariate model based on demographics, logit specification, DV: Q11_d
fig3.3_mod <- svyglm(Q11_d ~ dem + rep + ideo3 + 
                       male + white + black + hispanic + asian + 
                       income5 + dem*EDUC5 + rep*EDUC5 + unemployed + married + 
                       silent + boomer + genx + millen + 
                       activeduty + vet + social + family + 
                       midwest + south + west + 
                       catholic + christian + norelig +
                       city + rural + 
                       A2 + A3 + A4 + A5 + A6 + A7 + A8,
                     family = binomial(link = "logit"),
                     design = w2_design)

summary(fig3.3_mod)
check_collinearity(fig3.3_mod)
stargazer(fig3.3_mod)

